package com.sniper.springmvc.data;

import com.sniper.springmvc.model.AdminGroup;
import com.sniper.springmvc.mybatis.service.impl.AdminGroupService;
import com.sniper.springmvc.security.SpringContextUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 暂未使用
 * Created by suzhen on 2017/3/29.
 */
public class AdminGroupData {

    private static AdminGroupService groupService;

    static {
        groupService = SpringContextUtil.getBean(AdminGroupService.class);
    }

    private static Map<String, AdminGroup> GROUPS = new HashMap<>();

    static {
        List<AdminGroup> groups = groupService.pageList(null);
        for (AdminGroup group : groups) {
            GROUPS.put(group.getValue(), group);
        }
    }

    public AdminGroup get(String value) {
        return GROUPS.containsKey(value) ? GROUPS.get(value) : null;
    }


}
